<template>
	<!-- 下拉菜单示例 -->
	<view>
		<view class="screen">
			<c-dropdown :show="show1" :data="list" @close="show1 = false" v-model="checkIndex" @handle="handleFn">
				<view class="sc-font" @click="openDropdown(0)">
					<text>职业</text>
					<image class="sc-arrow" src="../static/arrow.png"></image>
				</view>
			</c-dropdown>
			<view class="sc-line"></view>
			<c-dropdown :show="show2" :data="list2" @close="show2 = false">
				<view class="sc-font" @click="openDropdown(1)">
					<text>身高</text>
					<image class="sc-arrow" src="../static/arrow.png"></image>
				</view>
			</c-dropdown>
			<view class="sc-line"></view>
			<c-dropdown :show="show3" :data="list3" @close="show3 = false">
				<view class="sc-font" @click="openDropdown(2)">
					<text>体重</text>
					<image class="sc-arrow" src="../static/arrow.png"></image>
				</view>
			</c-dropdown>
			<view class="sc-line"></view>
			<c-dropdown :show="show4" :data="list4" @close="show4 = false" custom>
				<view class="sc-font" @click="openDropdown(3)">
					<text>筛选</text>
					<image class="sc-screen" src="../static/screen.png"></image>
				</view>
				<template v-slot:bottom>
					<view class="more">
						<view class="mo-title">筛选条件</view>
						<view class="mo-box">
							<view class="mo-option" @click.stop="openCheck(0)">
								<view class="mo-left">性别</view>
								<view class="mo-right">
									<text>选择</text>
									<image src="../static/go.png" mode=""></image>
								</view>
							</view>
							<view class="mo-option" @click.stop="openCheck(1)">
								<view class="mo-left">年龄</view>
								<view class="mo-right">
									<text>选择</text>
									<image src="../static/go.png" mode=""></image>
								</view>
							</view>
							<view class="mo-option" @click.stop="openCheck(2)">
								<view class="mo-left">地区</view>
								<view class="mo-right">
									<text>选择</text>
									<image src="../static/go.png" mode=""></image>
								</view>
							</view>
						</view>
						<view class="mo-controls">
							<view class="mo-reset">重置</view>
							<view class="mo-btn">确定</view>
						</view>
					</view>
				</template>
			</c-dropdown>
		</view>
		<view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
			<view>这是内容1</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				show1: false,
				show2: false,
				show3: false,
				show4: false,
				from: {
					serviceType: 1,
					searchTime: '',
					role: '',
					pageNum: 1
				},
				showIndex: 0,
				showList: ['show1', 'show2', 'show3', 'show4'],
				checkIndex: 0,
				list: ['职业一', '职业二', '职业三', '职业四', '职业五'],
				list2: ['150cm-155cm', '156cm-160cm', '161cm-165cm', '166cm-170cm', '190cm以上'],
				list3: ['50kg-60cm', '61kg-70kg', '71kg-80kg', '81kg-90kg', '91kg-100kg'],
			}
		},
		methods: {
			// 打开选框
			openDropdown(inx) {
				let istrue = this[this.showList[inx]]
				this.showList.forEach(v => {
					if (this[v]) {
						this[v] = false
					}
				})
				this[this.showList[inx]] = istrue ? false : true
			},
			// 关闭选择
			close() {
				this.show1 = false
				this.show2 = false
				console.log('关闭了');
			},
			// 点击选择框
			handleFn(val, inx) {
				this.checkIndex = inx
				setTimeout(()=>{
					this.show1 = false
				},50)
				console.log('val', val);
				console.log('inx', inx);
			},
			// 点击打开选框
			openCheck(){
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.screen {
		display: flex;
		align-items: center;
		justify-content: space-around;
		// padding: 30rpx 0;
		height: 80rpx;

		.sc-line {
			width: 1rpx;
			height: 24rpx;
			background: #C7C9CC;
			border-radius: 0rpx;
		}

		.sc-font {
			display: flex;
			align-items: center;
			position: relative;

			.sc-arrow {
				width: 16rpx;
				height: 10rpx;
				margin-left: 8rpx;
			}

			.sc-screen {
				width: 20rpx;
				height: 18rpx;
				margin-left: 8rpx;
			}
		}

		.more {
			background: #fff;
			padding: 24rpx 30rpx 20rpx;
			.mo-title {
				font-size: 28rpx;
				font-weight: bold;
				color: #333333;
			}
			.mo-box{
				.mo-option{
					padding: 28rpx 0;
					border-bottom: 1rpx solid #E6E6E6;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.mo-left{
						font-size: 24rpx;
						color: #333333;
					}
					.mo-right{
						display: flex;
						align-items: center;
						font-size: 24rpx;
						font-weight: 400;
						color: #666666;
						image{
							width: 20rpx;
							height: 20rpx;
							margin-left: 12rpx;
						}
					}
				}
			}
			.mo-controls{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-top: 20rpx;
				.mo-reset{
					font-size: 36rpx;
					color: #333333;
					margin-left: 50rpx;
				}
				.mo-btn{
					width: 480rpx;
					height: 80rpx;
					background: $c-bgColor;
					border-radius: 12rpx;
					font-size: 36rpx;
					font-weight: bold;
					color: #FFFFFF;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
		}
	}
</style>